package com.yixun.qfbao.hander;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yixun.qfbao.api.service.ResourcesService;
import com.yixun.qfbao.apidto.GetUserAuthListReqDto;
import com.yixun.qfbao.apidto.GetUserAuthListResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.utils.LoginUtils;
import com.yixun.qfbao.vo.GetUserAuthListReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * 获取用户权限
 * @author JHSong
 * @create 2017-11-22 9:56
 **/
@Service("getUserAuthListHander")
public class GetUserAuthListHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetUserAuthListHander.class);

    @Autowired
    private ResourcesService resourcesService;

    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        BaseResponseDTO<GetUserAuthListResDto> res = new BaseResponseDTO<>();
        GetUserAuthListReqVo GetUserAuthListReqVo = (GetUserAuthListReqVo)reqDto;
        GetUserAuthListReqDto GetUserAuthListReqDto = GetUserAuthListReqVo.getParams();
        try {
            GetUserAuthListResDto resDto = resourcesService.getUserAuthList(GetUserAuthListReqDto);
            res.setResult(resDto.getResult());
            res.setResData(resDto);
        } catch (Exception e) {
            logger.error("GetUserAuthListHander error: {}", e);
            res.setResult(ResultEnum.FAIL.getNo());
            res.setErrorMsg("获取角色列表失败");
        }
        return res;
    }
}
